import request from '@/utils/request';
/**
 *获取公司人员列表
 *
 * @export POST
 * @param {integer} companyCode 公司code
 * @returns
 */
export async function getEmployeeList(companyCode, extra = {}) {
    const params = companyCode ? { administrativeOrganizationCode: companyCode } : {};
    const res = await request('/api/uc/org/employee/v1/employee/simple/info/list', {
        method: 'POST',
        data: {
            ...params,
            serviceStatus: [1, 2, 4, 5],
            ...extra
        }
    });
    const { code, data } = res;
    if (code === 10000) {
        // 过滤掉admin
        const finalData = {
            ...res,
            data: data.filter(item => item.employeeCode !== 'oa1135823925744009218' || item.employeeName !== 'admin')
        };
        return Promise.resolve(finalData);
    }
    return Promise.reject(res);
    // return request('/api/oa/v1/employee/getemployeelist', {
    //     method: 'POST',
    //     data: {
    //         companyId
    //     }
    // });
}

/**
 *获取我发起的任务列表
 */
export async function getLaunchTaskList(params) {
    return request('/api/oa/v1/work/task/taskinfos/my/launched', {
        method: 'POST',
        data: params
    });
}

/**
 *获取近期发起的任务列表
 */
export async function getRecentLaunchTaskList(params) {
    return request('/api/oa/v1/work/task/taskinfos/recent/my/launched', {
        method: 'POST',
        data: params
    });
}

/**
 *获取我执行的任务列表
 */
export async function getExecuteTaskList(params) {
    return request('/api/oa/v1/work/task/taskinfos/my/executed', {
        method: 'POST',
        data: params
    });
}

/**
 *获取待我执行的任务列表
 */
export async function getToExecuteTaskList(params) {
    return request('/api/oa/v1/work/task/taskinfos/my/to/execute', {
        method: 'POST',
        data: params
    });
}

/**
 *获取我参与的任务列表
 */
export async function getParticipateTaskList(params) {
    return request('/api/oa/v1/work/task/taskinfos/my/participated', {
        method: 'POST',
        data: params
    });
}

/**
 *获取近期参与的任务列表
 */
export async function getRecentParticipateTaskList(params) {
    return request('/api/oa/v1/work/task/taskinfos/recent/my/participated', {
        method: 'POST',
        data: params
    });
}

/**
 *获取待审核的任务列表
 */
export async function getNeedAuditTaskList(params) {
    return request('/api/oa/v1/work/task/taskinfos/my/to/audit', {
        method: 'POST',
        data: params
    });
}

/**
 *获取已审核的任务列表
 */
export async function getIsAuditTaskList(params) {
    return request('/api/oa/v1/work/task/taskinfos/my/audited', {
        method: 'POST',
        data: params
    });
}

/**
 *获取新闻类别
 *
 * @export GET
 * @param {string} applicationNo
 * @returns
 */
export async function getNewsType() {
    return request('/api/officialwebsite/v1/news/type/list', {
        method: 'GET'
    });
}

/**
 *获取任务详情-详细信息
 *
 * @export GET
 * @param {string} id
 * @returns
 */
export async function getTaskInfo(params) {
    return request(`/api/oa/v1/work/task/taskinfos/${params.id}`, {
        method: 'GET'
    });
}

/**
 *获取任务详情-详细信息
 *
 * @export GET
 * @param {string} id
 * @returns
 */
export async function getTaskSubtask(params) {
    return request(`/api/oa/v1/work/task/taskinfos/${params.id}/subtask`, {
        method: 'GET'
    });
}

/**
 *发起任务
 *
 * @export POST
 * @param {string}
 * @returns
 */
export async function launchTask(params) {
    return request('/api/oa/v1/work/task/taskinfos/launch', {
        method: 'POST',
        data: params
    });
}

/**
 *前置任务列表
 *
 * @export POST
 * @param {string}
 * @returns
 */
export async function frontTask(params) {
    return request('/api/oa/v1/work/task/taskinfos/front', {
        method: 'POST',
        data: params
    });
}

/**
 *关联任务列表
 *
 * @export POST
 * @param {string}
 * @returns
 */
export async function relateTaskList(params) {
    return request('/api/oa/v1/work/task/taskinfos/relation', {
        method: 'POST',
        data: params
    });
}

/**
 *获取任务详情-任务环节
 *
 * @export GET
 * @param {string} id
 * @returns
 */
export async function getTaskSteps(params) {
    return request(`/api/oa/v1/work/task/taskinfos/${params.id}/task_steps`, {
        method: 'GET'
    });
}
/**
 *获取任务详情-执行周期
 *
 * @export GET
 * @param {string} id
 * @returns
 */
export async function getCycles(params) {
    return request(`/api/oa/v1/work/task/taskinfos/${params.id}/cycles`, {
        method: 'GET'
    });
}
/**
 *获取任务详情-操作记录
 *
 * @export GET
 * @param {string} id
 * @returns
 */
export async function getOperateRec(params) {
    return request(`/api/oa/v1/work/task/taskinfos/${params.id}/operate_contents`, {
        method: 'GET'
    });
}
/**
 *获取任务详情-变更记录
 *
 * @export GET
 * @param {string} id
 * @returns
 */
export async function getOperateCon(params) {
    return request('/api/oa/v1/work/task/taskinfos/operate_change_records', {
        method: 'POST',
        data: params
    });
}

/**
 *获取待我验收的任务列表
 *
 * @export POST
 * @param {integer} pageNo 页码
 * @param {integer} pageSize 分页条数
 * @param {integer} sort 排序
 * @param {string} keyword 搜索内容
 * @returns
 */
export async function getPendingAcceptanceTaskList(params) {
    return request('/api/oa/v1/work/task/taskinfos/my/to/accept', {
        method: 'POST',
        data: params
    });
}

/**
 *获取我已验收的任务列表
 *
 * @export POST
 * @param {integer} pageNo 页码
 * @param {integer} pageSize 分页条数
 * @param {integer} sort 排序
 * @param {string} keyword 搜索内容
 * @returns
 */
export async function getAcceptedTaskList(params) {
    return request('/api/oa/v1/work/task/taskinfos/my/accepted', {
        method: 'POST',
        data: params
    });
}
/**
 *获取任务变更记录详情-详细信息
 *
 * @export GET
 * @param {string} id
 * @param {string} operateId
 * @returns
 */
export async function getChangeRecDetail(params) {
    return request(`/api/oa/v1/work/task/taskinfos/${params.id}/change_records/${params.operateId}`, {
        method: 'GET'
    });
}
/**
 *发起变更任务
 *
 * @export GET
 * @param {string} id
 * @returns
 */
export async function addChangeTask(params) {
    return request(`/api/oa/v1/work/task/taskinfos/${params.id}`, {
        method: 'PUT',
        data: params
    });
}

/**
 * 人工评分规指标查询
 * @param {object} params
 */
export async function getManualGradeRuleList(params) {
    return request('/api/oa/v1/task/artificial_score_rule/list_target', {
        method: 'POST',
        data: params
    });
}

/**
 * 人工评分规指标详情
 * @param {integer} id
 */
export async function getManualGradeRuleDetail(id) {
    return request(`/api/oa/v1/task/artificial_score_rule/get_detail/${id}`, {
        method: 'GET'
    });
}

/**
 * 人工评分规指标新增
 * @param {object} params
 */
export async function addManualGradeRule(params) {
    return request('/api/oa/v1/task/artificial_score_rule/add_target', {
        method: 'POST',
        data: params
    });
}

/**
 * 人工评分规指标编辑
 * @param {object} params
 */
export async function editManualGradeRule(params) {
    return request('/api/oa/v1/task/artificial_score_rule/edit_target', {
        method: 'POST',
        data: params
    });
}

/**
 * 人工评分规指标删除
 * @param {integer} id
 */
export async function deleteManualGradeRule(id) {
    return request(`/api/oa/v1/task/artificial_score_rule/delete_target/${id}`, {
        method: 'POST'
    });
}

/**
 *工作量管理-全部任务-待发起
 *
 * @export POST
 * @param {object} params
 * @returns
 */
export async function getEstimationlaunch(params) {
    return request('/api/oa/v1/work/task/taskinfos/estimation/to_launch', {
        method: 'POST',
        data: params
    });
}

/**
 *工作量管理-全部任务-已发起
 *
 * @export POST
 * @param {object} params
 * @returns
 */
export async function getEstimationlaunched(params) {
    return request('/api/oa/v1/work/task/taskinfos/estimation/launched', {
        method: 'POST',
        data: params
    });
}
/**
 *工作量管理-全部任务-无需估算
 *
 * @export POST
 * @param {object} params
 * @returns
 */
export async function getEstimationnotrequired(params) {
    return request('/api/oa/v1/work/task/taskinfos/estimation/not_required', {
        method: 'POST',
        data: params
    });
}

/**
 *我的估算-待估算和已估算
 *
 * @export POST
 * @param {object} params
 * @returns
 */
export async function getEstimatedTaskList(params) {
    return request('/api/oa/v1/work/task/estimation/myestimationoftasklist', {
        method: 'POST',
        data: params
    });
}

/**
 *保存评分、估算自定义人员
 *
 * @export POST
 * @param {object} params
 * @returns
 */
export async function saveTaskUserConfig(params) {
    return request('/api/oa/v1/work/task/user_configs', {
        method: 'POST',
        data: params
    });
}

/**
 * 获取评分、估算自定义人员
 * @param {string} type
 */
export async function getTaskUserConfig(type) {
    return request(`/api/oa/v1/work/task/user_configs/${type}`, {
        method: 'GET'
    });
}

/**
 *搜索获取上一级任务
 *
 * @export POST
 * @param {object} params
 * @returns
 */
export async function searchParentTask(params) {
    return request('/api/oa/v1/work/task/taskinfos/select_parent_task', {
        method: 'POST',
        data: params
    });
}
